'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.changeKey = undefined;

var _has = require('lodash/has');

var _has2 = _interopRequireDefault(_has);

var _set = require('lodash/set');

var _set2 = _interopRequireDefault(_set);

var _unset = require('lodash/unset');

var _unset2 = _interopRequireDefault(_unset);

var _get = require('lodash/get');

var _get2 = _interopRequireDefault(_get);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var changeKey = exports.changeKey = function changeKey(obj, keyPath, newKeyPath, value) {
    if (!(0, _has2.default)(obj, keyPath)) {
        return;
    }
    (0, _set2.default)(obj, newKeyPath, value || (0, _get2.default)(obj, keyPath));
    (0, _unset2.default)(obj, keyPath);
};

exports.default = changeKey;